Full source code giải đố hình đơn giản
16.649 lượt xem;
- SettingsController.cs
- Puzzle Menu Controller Scripts /
- Scripts /
- Assets /
- project /
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.UI;
5
6 public class SettingsController : MonoBehaviour {
7
8 [SerializeField]
9 private MusicController musicController;
10
11 [SerializeField]
12 private GameObject settingsPanel;
13
14 [SerializeField]
15 private Animator settingsPanelAnim;
16
17 [SerializeField]
18 private Slider slider;
19
20 public void OpenSettingsPanel()
21 {
22 slider.value = musicController.GetMusicVolume();
23 settingsPanel.SetActive(true);
24 settingsPanelAnim.Play("Slide_In");
25 }
26
27 public void CloseSettingsPanel()
28 {
29 StartCoroutine(CloseSettings());
30 }
31
32 IEnumerator CloseSettings()
33 {
34 settingsPanelAnim.Play("Slide_Out");
35 yield return new WaitForSeconds(1f);
36 settingsPanel.SetActive(false);
37 }
38
39 public void GetVolume(float volume)
40 {
41 musicController.SetMusicVolume(volume);
42 }
43
44 }
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.UI;
5
6 public class SettingsController : MonoBehaviour {
7
8 [SerializeField]
9 private MusicController musicController;
10
11 [SerializeField]
12 private GameObject settingsPanel;
13
14 [SerializeField]
15 private Animator settingsPanelAnim;
16
17 [SerializeField]
18 private Slider slider;
19
20 public void OpenSettingsPanel()
21 {
22 slider.value = musicController.GetMusicVolume();
23 settingsPanel.SetActive(true);
24 settingsPanelAnim.Play("Slide_In");
25 }
26
27 public void CloseSettingsPanel()
28 {
29 StartCoroutine(CloseSettings());
30 }
31
32 IEnumerator CloseSettings()
33 {
34 settingsPanelAnim.Play("Slide_Out");
35 yield return new WaitForSeconds(1f);
36 settingsPanel.SetActive(false);
37 }
38
39 public void GetVolume(float volume)
40 {
41 musicController.SetMusicVolume(volume);
42 }
43
44 }